package com.zxl.controller;

import com.zxl.model.MetaColumn;
import com.zxl.model.MetaTable;
import com.zxl.service.DataKindredService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/data/kinder")
public class DataKindredController {

    @Resource
    private DataKindredService dataKindredService;

    @ApiOperation(value = "数据开发HiveSQL/pgsql解析导入血缘库")
    @PostMapping("/devParseDataImport/{typeFlag}/{jobId}/{jobName}")
    public void devParseDataImport(@RequestBody String sql, @PathVariable("jobId") Integer jobId, @PathVariable("jobName") String jobName) {
        dataKindredService.devParseDataImport(sql.replaceAll("--(.*)[\n\r]", ""), jobId, jobName);
    }

    @ApiOperation(value = "删除表血缘接口")
    @PostMapping("/deletedTableRelation")
    public void deletedTableRelation(@RequestBody Integer busied) {
        dataKindredService.deletedTableRelation(busied);
    }

    @ApiOperation(value = "删除字段血缘接口")
    @PostMapping("/deletedColumnRelation")
    public void deletedColumnRelation(@RequestBody Integer busied) {
        dataKindredService.deletedColumnRelation(busied);
    }

    @ApiOperation(value = "更新表血缘信息")
    @PostMapping("/updateTableRelation")

    public void updateTableRelation(@RequestBody MetaTable metaTable) {
        dataKindredService.updateTableRelation(metaTable);
    }

    @ApiOperation(value = "更新字段血缘信息")
    @PostMapping("/updateColumnRelation")
    public void updateColumnRelation(@RequestBody MetaColumn metaColumn) {
        dataKindredService.updateColumnRelation(metaColumn);
    }
}
